var BeginToShowWindow = function(){
	this.init();
}

BeginToShowWindow.prototype={
	init: function(){
		var _this = this;
		// 选择时间和日期
		$(".form-datetime").datetimepicker({
			weekStart: 1,
			todayBtn: 1,
			autoclose: 1,
			todayHighlight: 1,
			startView: 2,
			forceParse: 0,
			showMeridian: 1,
			format: "yyyy-mm-dd hh:ii"
		});
		_this.typeChange();
		
		//推广方案
		new ModalChoseTable({
			modalSize: "400px",
			id: "games",
			dataUrl: "http://112.124.121.34:8091/shihou.forum.service/forum/query?activityId=3149",
			dataParameter: {"activityId":"3149"},
			itemNameKey: 'content',
			itemIdKey: 'id'
		});
	},
	/**
	 * 点击类型radio进行变换
	 */
	typeChange: function(){
		var type = ['quanju', 'game', 'user'];
		$('.ad-type input[type=radio]').click(function(){
			var value = $(this).val();
			switch(value){
				case "1":
					swichoverShow(type[0]);
					break;
				case "2":
					swichoverShow(type[1]);
					break;
				case "3":
					swichoverShow(type[2]);
					break;
				default:
					break;
			}
		});
		
		function swichoverShow(show){
			//先隐藏，再显示。这样的做法时因为房间活动和全局房间活动公用【弹窗图片】
			type.forEach(function(value){
				$("."+value).hide();
			});
			$("."+show).show();
		}
		
		//初始化时，触发点击【房间活动】radio
		$('.ad-type input[type=radio]').eq(0).click();
	}
}

$(document).ready(function(){
	new BeginToShowWindow();
});